#-*- Makefile -*-

## This is only used when building R itself but it does customize
## etc/*/Makeconf: see fixed/Makefile

## Customize by copying to MkRules.local and uncommenting and editing 
## some of the definitions there. The values are tailored to Rtools45, the
## currently recommended toolchain using gcc 14, MinGW-w64 11, 64-bit only,
## UCRT. R is only intended to be built for 64-bit UCRT as of R 4.2. The
## values also work with Rtools45 on aarch64 (LLVM 19, clang/flang-new, lld,
## libc++) via USE_LLVM=1 and WIN=.

## =========== configuration macros for building packages ================

# LOCAL_SOFT is intended to point to software collection with static
# libraries and headers installed "outside of Rtools", in the same spirit as
# software is installed on Linux into '/usr/local' if it is not available in
# the respective Linux distribution. 
#
# CRAN distributed this software and running 'make rsync-extsoft' would
# populate the default directory $(R_HOME)/extsoft.  The versions used on
# CRAN recommended for R 2.14.2 to 3.2.4 can still be found at
# https://www.stats.ox.ac.uk/pub/Rtools/libs.html
#
# Eventually, this software collection became part of Rtools, so it should
# no longer be referred to via LOCAL_SOFT.  Rtools42 hence introduce
# variable R_TOOLS_SOFT for use in R packages to refer to headers or
# libraries in the Rtools software collection (which in turn can be
# influenced by R_CUSTOM_TOOLS_SOFT for packages).  LOCAL_SOFT should not be
# used for that purpose.  R source code refers to that software collection
# using EXT_LIBS.
#
# However, a number of CRAN packages ended up referring to Rtools software
# collection via LOCAL_SOFT, so LOCAL_SOFT is set up by default to also
# point to the Rtools software. This may be changed in the future.
#
# To build R from source with Rtools45 (installed from installer as well as
# tarball), gcc has to be on PATH and LOCAL_SOFT can be computed as follows:
#
# LOCAL_SOFT ?= $(shell which `echo $(CC) | sed -e 's/ .*//g'` | sed -e 's!/bin/[^/]\+!!g')
#
## ============== configuration macros for building R ===================

# Path of library directory containing zlib, bzlib, liblzma, pcre,
# libpng, libjpeg, libtiff, xz.
# EXT_LIBS = $(LOCAL_SOFT)

# Set to 1 when using LLVM (e.g.  with the recommended toolchain for
# aarch64)
# USE_LLVM =

# Set to NO to disable pkg-config. Otherwise, pkg-config will be used when
# available to figure out C preprocessor flags and linking commands to link
# R (and packages part of R distribution) against external libraries.
# It is assumed that when available, pkg-config is on PATH.
# USE_PKG_CONFIG =

# Debug flag, -gdward-2 can be used with GCC, -g3 can be used with clang.
# G_FLAG = -gdwarf-2

# Set to YES and specify the path if you want to use the ATLAS BLAS.
# USE_ATLAS = NO
# ATLAS_PATH =

# Set to YES if you want to use OPENBLAS. OPENBLAS libraries are looked up
# using pkg-config. OPENBLAS and pkg-config are part of Rtools.
# USE_OPENBLAS = NO

# Support for the ACML and Goto BLASes has been withdrawn: see R-admin.html

# Define to use svnversion to set SVN-REVISION (slow, and requires a clean
# checkout with no modifications).
# USE_SVNVERSION = YES

# Some of the toolchains have prefixes for e.g.  ar, gcc.  This can also be
# used to give the full path to the compiler, including a trailing / .  When
# cross-compiling using the recommended toolchain, one would set this to
# aarch64-w64-mingw32.static.posix- for aarch64 and to
# x86_64-w64-mingw32.static.posix- for x86_64 target.
# BINPREF64 =

# Set this to indicate a non-gcc compiler and version
# COMPILED_BY = <determined automatically>

# Others use a -m64 or -m32 option to select architectures
# M_ARCH =
# and for as (--32 or --64)
# AS_ARCH =
# and for windres (-F pe-i386 or pe-x86-64)
# RC_ARCH =
# and for dlltool ("-m i386 --as-flags --32" vs "-m i386:x86-64 --as-flags --64")
# DT_ARCH =

# The gcc 4.9.3 64 bit toolchain is set up for the 'medium code' model and needs
# to remove the .refptr and .weak entries from the exports list; this is the default
# NM_FILTER = | $(SED) -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d'

# We normally link directly against DLLs, 
# but this macro forces the use of import libs
# Has been needed for some versions of MinGW-w64
# USE_IMPLIBS = YES


# set to use ICU
# USE_ICU = YES
# path to parent of ICU headers
# ICU_PATH =
# needed libs varies by version and build.
# ICU_LIBS = -lsicuin -lsicuuc $(EXT_LIBS)/lib/sicudt.a -lstdc++

# set to use libcurl
# USE_LIBCURL = YES
# path to parent of libcurl headers
# CURL_PATH =
# libs: currently recommended toolchain
# CURL_LIBS= -lcurl -lpsl -lbcrypt -lzstd -lrtmp -lssl -lssh2 -lbcrypt -lgcrypt \
#            -lcrypto -lgdi32 -lz \
#            -lws2_32 -lgdi32 -lcrypt32 -lidn2 -lunistring -liconv -lgpg-error -lwldap32 \
#            -lwinmm -lbrotlidec -lbrotlicommon

# For the cairographics devices:
# set to build cairo devices in "cairodevices" or "distribution" targets
# (they are not built in "all" even if this is set)
# USE_CAIRO = YES
# set to cairo headers (included in the recommended toolchain, but under "cairo")
# CAIRO_CPPFLAGS = "-I$(EXT_LIBS)/include/cairo -I$(EXT_LIBS)/include/freetype2 \
#                   -DCAIRO_WIN32_STATIC_BUILD"
# set to cairo libraries (included in the recommended toolchain)
# CAIRO_LIBS = "-lcairo -lfontconfig -lfreetype -lpng -lpixman-1 -lexpat -lharfbuzz \
#               -lbz2 -lintl -lz -liconv -luuid -lstdc++ -lgdi32 -lmsimg32 -lole32 \
#               -lbrotlidec -lbrotlicommon"
#
# Previous versions of R used CAIRO_HOME and an empty value meant to not
# build cairo. This is no longer used.

# set this to YES to build static HTML help
# BUILD_HTML = NO

# set to use MiKTeX (and unset otherwise)
# MIKTEX = TRUE
# TEXI2DVI = texi2dvi
# MiKTEX no longer provides texi2dvi and needs something like (previous toolchains)
# TEXI2DVI = TEXINDEX=/Rtools/bin/texindex.exe texify
# with the currently recommended toolchain, Msys2 texi2dvi is used, but needs a workaround for a bug
# TEXI2DVI = env COMSPEC= texi2dvi

# For Texinfo >= 6.1. If the texinfo files are installed at /packages/texinfo,
# TEXI2ANY = /path/to/perl -I/packages/texinfo /packages/texinfo/texi2any
# if you do not have texinfo (default),
# TEXI2ANY = missing

# C standard to use by default (override the compiler default)
# CSTD = -std=gnu2x

# additional optimization flags (e.g. -mtune=native for a private build)
#
# -mstackrealign is used to avoid traps due to misaligned addresses with
#   SSE2 (seen on 32-bit builds with forced SSE2 using -mfpmath=sse -msse2,
#   probably not needed on 64-bit builds)
#
# -fexceptions was used as a workaround for GCC 10.3.0 bug causing crashes in
#   long jumps due to invalid unwind tables. This is the only reason for
#   this option as R does not use structured exception handling from C.
#   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103274
#   
#   -fno-reorder-blocks-and-partition was not a suitable workaround because
#   of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103465
#
#   (reorder-blocks-and-partition has been fixed in GCC, so -fexceptions
#   should no longer be needed for newer versions of GCC and the recommended
#   toolchain)
#
# -Wa,-muse-unaligned-vector-move can be used to make binutils (on x86_64)
#   turn vectorized instructions requiring aligned vectors into instructions
#   not requiring them; this can be used as a work-around when compiling with
#   GCC with AVX2 instructions enabled, for a bug due to which GCC does not
#   ensure that local variables are 32-byte aligned. See
#   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412
#   This bug is still present in GCC 13.
#
# EOPTS = -mfpmath=sse -msse2 -mstackrealign $(LTO)

# sanitizer options to be passed to the compiler and linker; this requires
# support in the compiler toolchain
# e.g. -fsanitize=address,undefined,bounds
# SANOPTS = 

# define to -fopenmp if the toolchain has OpenMP support
# OPENMP = -fopenmp

# define to -pthread if the toolchain has pthreads support
# PTHREAD = -pthread

# define to use Link-Time Optimization.
# standard value is -flto, or e.g. -flto=8 to use 8 threads
# LTO =
# flag for use with Rcmd INSTALL --use-LTO
# LTO_OPT =

## ====== configuration macros for building installer ===========

# location where Inno Setup 6 was installed. Spaces allowed.
# ISDIR = C:/Program Files (x86)/Inno Setup 6

# optional location where qpdf was installed (in $(QPDF)/bin). Spaces allowed.
# QPDF =

# Full paths of extra DLLs that need to be shipped
# e.g
# DLLs64 =

# External build-tree with pre-compiled (e.g. cross-compiled) R binaries.
# Can be used to cross-compile installer for Windows/aarch64 on
# Windows/x86_64.
# CROSS_BUILD =

## ====== configuration macros for building MSI installer ===========

# location where WiX 3.x executables were installed. Spaces allowed.
# The MSI uses '/bin': other packagings may not
# WIX3DIR = C:/packages/WiX3.14/bin

# set to 1 for a non-elevated per-user installer
# WIX_PERSONAL = 0

## =============== end of user-customizable parts  ===================
